package castledefense.game;

import twl.global.libgdx.GlobalInputMultiplexer;
import twl.global.libgdx.GlobalTWL;
import castledefense.sound.SoundHandler;
import castledefense.data.GameData;
import castledefense.data.Resources;
import castledefense.game.screens.MainGameScreen;

import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class CastleDefense extends Game {
	public void create() {
		GameData.resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
		
		Resources.init();		
		SoundHandler.init();
		SpriteBatch spriteBatch = new SpriteBatch();
		GlobalTWL twl = new GlobalTWL(spriteBatch, "res/ThemeAll.xml",
				FileType.Internal);

		Gdx.gl.glDisable(GL10.GL_LIGHTING);
		Gdx.gl.glDisable(GL10.GL_DEPTH_TEST);
		Gdx.graphics.setVSync(true);
		
		
		MainGameScreen mainGameScreen = new MainGameScreen(spriteBatch, twl);
		setScreen(mainGameScreen);
		// Required to send input to twl and mainGameScreen
		GlobalInputMultiplexer inputMultiplexer = new GlobalInputMultiplexer();
		inputMultiplexer.addProcessor(twl);
		inputMultiplexer.addProcessor(mainGameScreen);
		Gdx.input.setInputProcessor(inputMultiplexer);
	}

	@Override
	public void dispose() {
		super.dispose();

		Resources.dispose();
		SoundHandler.dispose();
	}
}
